<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2018/7/16
 * Time: 10:03
 */
namespace app\admin\controller;
use think\Request;

class Set extends Common
{
    public function get(Request $request){
        $name = db('setting')->where('name',$request->param('name'))->find();
        return $name;
    }

    public function set(Request $request){
        $input = $request->param();

        $info = db('setting')->where('name',$input['name'])->find();
        if($info){
            $row = db('setting')->where('name',$input['name'])->update(['val'=>$input['val']]);
        }else{
            $row = db('setting')->insert(['name'=>$input['name'],'val'=>$input['val']]);
        }

        return ['code'=>1,'msg'=>'设置成功'];
    }
}